package com.bootdo.wx.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.bootdo.common.utils.R;
import com.bootdo.wx.dao.MemberSignRewardDao;
import com.bootdo.wx.domain.MemberSignRewardDO;
import com.bootdo.wx.service.MemberSignRewardService;



@Service
public class MemberSignRewardServiceImpl implements MemberSignRewardService {
	@Autowired
	private MemberSignRewardDao memberSignRewardDao;
	
	@Override
	public MemberSignRewardDO get(String id){
		return memberSignRewardDao.get(id);
	}
	
	@Override
	public List<MemberSignRewardDO> list(Map<String, Object> map){
		return memberSignRewardDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return memberSignRewardDao.count(map);
	}
	
	@Override
	public int save(MemberSignRewardDO memberSignReward){
		return memberSignRewardDao.save(memberSignReward);
	}
	
	@Override
	public int update(MemberSignRewardDO memberSignReward){
		return memberSignRewardDao.update(memberSignReward);
	}
	
	@Override
	public int remove(String id){
		return memberSignRewardDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return memberSignRewardDao.batchRemove(ids);
	}

    @Override
    public List<MemberSignRewardDO> likeList(Map<String, Object> map){
        return memberSignRewardDao.likeList(map);
    }

	@Override
	public R updateSignReward(Map<String, Object> params) {
		String addressId = params.get("addressId").toString();
		params.remove("addressId");
		params.put("delFlag", "0");
		List<MemberSignRewardDO> list = memberSignRewardDao.list(params);
		if(list.size()>0){
			list.get(0).setStatus(1);
			list.get(0).setUpAt(new Date());
			list.get(0).setAddressId(addressId);
			 memberSignRewardDao.update(list.get(0));
			 return R.ok().put("data", list.get(0));
		}
		return R.error("信息有误");
	}

	
}
